/**
 * 定义数据比对模块
 */
(function(window, angular, undefined){

	var module = angular.module('water.entity.dataComparison',['waterCommon']);
	
	module.service('$dataComparisonService',function($q,$waterDataCommon){
				
		/**
		 * 获取数据比对汇总列表
		 * queryObj:
		 * {
		 * 		MN:
		 * 		START:
		 * 		END:
		 * }
		 */
		this.getDataComparisonSummaryList = function(queryObj,onSuccess){
			var promise = $waterDataCommon.post("/DataComparison/getDataComparisonSummaryList",queryObj);
			return promise;
		}		
		/**
		 *获取数据比对信息表
		 * queryObj:
		 * {
		 * 		reportnumber:
		 * 		PARMNAME:
		 * }
		 */
		this.getComparisonList = function(queryObj){
			var promise = $waterDataCommon.post("/DataComparison/getComparisonList",queryObj);
			return promise;
		}
		/**
		 *通过报告编号获取监测参数
		 * queryObj:
		 * {
		 * 		reportnumber:
		 * }
		 */
		this.getMoinitorParam = function(queryObj){
			var promise = $waterDataCommon.post("/DataComparison/getMoinitorParam",queryObj);
			return promise;
		}
		/**
		 *获取数据比对详细信息表
		 * queryObj:
		 * {
		 * 		reportnumber:
		 * 		DETERTYPE:
		 * }
		 */
		this.getComparisonDetailList = function(queryObj){
			var promise = $waterDataCommon.post("/DataComparison/getComparisonDetail",queryObj);
			return promise;
		}

		this.updatedatacomparisoninfo = function(queryObj){
			var promise = $waterDataCommon.post("/DataComparison/updatedatacomparisoninfo",queryObj);
			return promise;
		}
		/**
		 * 根据站点ID获取企业基本数据
		 * queryObj:
		 * {
		 * 		STATION_ID:
		 * }
		 */
		this.getBaseInfoByStationID = function(queryObj,onSuccess){			
			var promise = $waterDataCommon.post("/DataComparison/getBaseInfoByStationID",queryObj);
			return promise;
		}
		
		
		/**
		 *  根据报告类型与时间，获取到报告为今天第几号，用于生成报告编号
		 * queryObj:
		 * {
		 * 		DATATIME:
		 * 		REPORTTYPE:
		 * }
		 */
		this.getReportNumber = function(queryObj,onSuccess){			
			var promise = $waterDataCommon.post("/DataComparison/getReportNumber",queryObj);
			return promise;
		}
		
		
		/**
		 * 新建比对报告基础信息dataComparisonSummary
		 */
		this.createComparisonSummaryModel = function(dataComparisonSummary){
			var promise = $waterDataCommon.createModel("DATACOMPARISONSUMMARY",dataComparisonSummary);
			return promise;
		}
		
		/**
		 * 更新比对报告基础信息dataComparisonSummary,只更新主表数据
		 */
		this.updateComparisonSummaryModel = function(dataComparisonSummary){
			var promise = $waterDataCommon.updateModel("DATACOMPARISONSUMMARY",dataComparisonSummary);
			return promise;
		}
		
		/**
		 * 更新比对报告基础信息dataComparisonSummary,同时更新子表数据
		 */
		this.updateComparisonSummaryModelWithChild = function(dataComparisonSummary){
			var promise = $waterDataCommon.updateModelWithChild("DATACOMPARISONSUMMARY",dataComparisonSummary);
			return promise;
		}
		
		/**
		 * 新建数据比对信息表DATACOMPARISONINFO
		 */
		this.createComparisonModel = function(DataComparisonInfo){
			if(DataComparisonInfo.GUID==undefined||DataComparisonInfo.GUID==""){
				var promise = $waterDataCommon.createModel("DATACOMPARISONINFO",DataComparisonInfo);
			}else{
				var promise = $waterDataCommon.updateModel("DATACOMPARISONINFO",DataComparisonInfo);
			}
			return promise;
		}
		
		/**
		 * 删除数据比对信息表DATACOMPARISONINFO
		 */
		this.deleteComparisonModel = function(id){
			var promise = $waterDataCommon.deleteModel("DATACOMPARISONINFO",{key:id});
			return promise;
		}

		/**
		 * 新建数据比对详细信息表DATACOMPARISONDETAILINFO
		 */
		this.createComparisonDetailModel = function(DataComparisonDetailInfo){
			if(DataComparisonDetailInfo.GUID==undefined||DataComparisonDetailInfo.GUID==""){
				var promise = $waterDataCommon.createModel("DATACOMPARISONDETAILINFO",DataComparisonDetailInfo);
			}else{
				var promise = $waterDataCommon.updateModel("DATACOMPARISONDETAILINFO",DataComparisonDetailInfo);
			}		
			return promise;
		}
		/**
		 * 删除数据比对详细信息表DATACOMPARISONDETAILINFO
		 */
		this.deleteComparisonDetailModel = function(id){
			var promise = $waterDataCommon.deleteModel("DATACOMPARISONDETAILINFO",{key:id});
			return promise;
		}
		/**
		 * 获取站点具体时间的监测数据
		 */
		this.getMonitorDataMin = function(queryObj){			
			var promise = $waterDataCommon.post("/DataComparison/getMonitorDataMin",queryObj);
			return promise;
		}
		
		/**
		 * 导出数据比对报告
		 */
		this.exportDataComparison = function(queryObj){
			queryObj._format = "word";
			var queryString = $waterDataCommon.jsonTostring(queryObj);
			window.open(getBasePath()+"/DataComparison/exportDataComparison.do?"+queryString);
		}

		/**
		 * 获取站点具体时间的监测数据
		 */
		this.updateMonitorEquipment = function(queryObj){			
			$waterDataCommon.post("/DataComparison/updateMonitorEquipment",queryObj);
		}
		/**
		 * 数据比对删除
		 */
		this.deleteDataComparison=function(queryObj){
			$waterDataCommon.post("/DataComparison/DeleteDatacomparisoninfo",queryObj);
		}
	})
}(window, angular));